package com.xyht.medicine_management_system.modules.kuaidi.controller;


import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.medicine_management_system.modules.kuaidi.entity.req.MmsKuaidiInfoReq;
import com.xyht.medicine_management_system.modules.kuaidi.entity.req.MmsKuaidiSettingReq;
import com.xyht.medicine_management_system.modules.kuaidi.service.MmsKuaidiSettingService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 发货地址配置 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-07-02
 */
@RestController
@RequestMapping("/kuaidi/setting")
@SecretBody
public class MmsKuaidiSettingController {
    @Resource
    private MmsKuaidiSettingService mmsKuaidiSettingService;

    @ApiOperation("添加发货地址")
    @PostMapping("/add")
    public ResponseResult addSetting(@RequestBody MmsKuaidiSettingReq settingReq) {
        return mmsKuaidiSettingService.addSetting(settingReq);
    }
    @ApiOperation("删除发货地址")
    @PostMapping("/delete")
    public ResponseResult deleteSetting(@RequestBody MmsKuaidiSettingReq settingReq) {
        return mmsKuaidiSettingService.deleteSetting(settingReq);
    }
    @ApiOperation("修改发货地址")
    @PostMapping("/update")
    public ResponseResult updateSetting(@RequestBody MmsKuaidiSettingReq settingReq) {
        return mmsKuaidiSettingService.updateSetting(settingReq);
    }
    @ApiOperation("开启/关闭发货地址")
    @PostMapping("/switch")
    public ResponseResult switchSetting(@RequestBody MmsKuaidiSettingReq settingReq) {
        return mmsKuaidiSettingService.switchSetting(settingReq);
    }
    @ApiOperation("获取发货地址列表")
    @GetMapping("/list")
    public ResponseResult getSettingList(@RequestParam(value = "searchStr",required = false) String searchStr,
                                         @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                         @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize) {
        return mmsKuaidiSettingService.getSettingList(searchStr, pageNum, pageSize);
    }
    @ApiOperation("获取发货地址详情")
    @GetMapping("/detail")
    public ResponseResult getSettingDetail(@RequestParam(value = "settingId") String settingId) {
        return mmsKuaidiSettingService.getSettingDetail(settingId);
    }


}

